{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Quantum Computing on Azure Quantum with Q# and Jupyter Notebook: <br> Parallel QRNG"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This notebook demonstrates how to execute a Q# program on Azure Quantum."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Define Q# operations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The quickest way to define a Q# operation in a Q# Jupyter Notebook is to simply write the Q# code directly into a notebook cell and execute it. Note that for convenience, the `Microsoft.Quantum.Canon` and `Microsoft.Quantum.Intrinsic` namespaces are automatically opened in every cell. This can take 30 seconds to run the first time, as the Q# environment is initializing."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/x-qsharp-data": "[\"SampleRandomNumber\"]",
      "text/html": [
       "<ul><li>SampleRandomNumber</li></ul>"
      ],
      "text/plain": [
       "SampleRandomNumber"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "open Microsoft.Quantum.Arrays;\n",
    "open Microsoft.Quantum.Measurement;\n",
    "    \n",
    "operation SampleRandomNumber() : Result[] {\n",
    "    // We prepare a register of qubits in a uniform\n",
    "    // superposition state, such that when we measure,\n",
    "    // all bitstrings occur with equal probability.\n",
    "    let nQubits = 5;\n",
    "    use register = Qubit[nQubits];\n",
    "\n",
    "    // Set qubits in superposition.\n",
    "    for qubit in register {\n",
    "        H(qubit);\n",
    "    }\n",
    "\n",
    "    // Measure all qubits and return.\n",
    "    return MeasureEachZ (register);\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using `%simulate`, you can invoke the built-in Q# functionality to simulate a quantum operation locally and return the result. You can specify any operation that has been defined in the notebook or that has been imported from a .qs file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/x-qsharp-data": "[1,0,0]",
      "text/html": [
       "<ul><li>One</li><li>Zero</li><li>Zero</li></ul>"
      ],
      "text/plain": [
       "One, Zero, Zero"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%simulate SampleRandomNumber"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Executing Q# operations in Azure Quantum"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First, find the resource ID of your Azure Quantum workspace. You can copy/paste this from the top-right corner of your Quantum Workspace page in Azure Portal.\n",
    "\n",
    "Next, you can run `%azure.connect` to connect to the workspace and display the list of provisioned targets that support execution of Q# programs. If you are prompted to login, be sure to use the same account you used to create your Azure Quantum workspace."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Authenticated using Azure.Identity.AzureCliCredential\n",
      "\n",
      "\n",
      "Connected to Azure Quantum workspace self-host in location westus.\n"
     ]
    },
    {
     "data": {
      "application/x-qsharp-data": "[{\"id\":\"ionq.qpu\",\"current_availability\":{},\"average_queue_time\":197},{\"id\":\"ionq.simulator\",\"current_availability\":{},\"average_queue_time\":0}]",
      "text/html": [
       "<table><thead><tr><th style=\"text-align: start;\">Target ID</th><th style=\"text-align: start;\">Current Availability</th><th style=\"text-align: start;\">Average Queue Time (Seconds)</th></tr></thead><tbody><tr><td style=\"text-align: start;\">ionq.qpu</td><td style=\"text-align: start;\">Available</td><td style=\"text-align: start;\">197</td></tr><tr><td style=\"text-align: start;\">ionq.simulator</td><td style=\"text-align: start;\">Available</td><td style=\"text-align: start;\">0</td></tr></tbody></table>"
      ],
      "text/plain": [
       "Target ID      Current Availability Average Queue Time (Seconds)\r\n",
       "-------------- --------- ---\r\n",
       "ionq.qpu       Available 197\r\n",
       "ionq.simulator Available 0\r\n"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%azure.connect \"/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Quantum/Workspaces/workspaceName\" location=\"westus\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, use `%azure.target` to specify the target you'd like to use for job submission. This may take a minute or so."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading package Microsoft.Quantum.Providers.IonQ and dependencies...\n",
      "Active target is now ionq.simulator\n"
     ]
    },
    {
     "data": {
      "application/x-qsharp-data": "{\"id\":\"ionq.simulator\",\"current_availability\":{},\"average_queue_time\":0}",
      "text/html": [
       "<table><thead><tr><th style=\"text-align: start;\">Target ID</th><th style=\"text-align: start;\">Current Availability</th><th style=\"text-align: start;\">Average Queue Time (Seconds)</th></tr></thead><tbody><tr><td style=\"text-align: start;\">ionq.simulator</td><td style=\"text-align: start;\">Available</td><td style=\"text-align: start;\">0</td></tr></tbody></table>"
      ],
      "text/plain": [
       "Target ID      Current Availability Average Queue Time (Seconds)\r\n",
       "-------------- --------- -\r\n",
       "ionq.simulator Available 0\r\n"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%azure.target ionq.simulator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To run a job, use `%azure.execute` along with the Q# operation name. The `%azure.execute` command will wait for the job to complete. Alternatively, you can use `%azure.submit`, which will submit the job and return immediately after the job is created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "%azure.execute SampleRandomNumber timeout=240"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Running `%azure.status` will display the status of the most recently submitted job in this session. If you want to check the status of a different job, provide the job ID to `%azure.status`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%azure.status"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also view the status of all jobs by using `%azure.jobs`. Providing a parameter to this command will filter to just the jobs containing that string. For example, you can query for the status of all jobs named `Microsoft.Quantum.AzureSamples.SampleRandomNumber`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%azure.jobs SampleRandomNumber"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Usage information"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to the `%simulate`, `%azure.connect`, and other commands shown above, Q# notebooks provide a wide range of other commands as well. Similar to other Jupyter-based languages, these commands are often called _magic commands_, and are used to interact with Q# notebooks themselves.\n",
    "\n",
    "To list all of the available magic commands, check out the [IQ# magic command references](https://docs.microsoft.com/qsharp/api/iqsharp-magic/), or run `%lsmagic`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/x-qsharp-data": "[{\"Name\":\"%azure.connect\",\"Documentation\":{\"Summary\":\"Connects to an Azure Quantum workspace or displays current connection status.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for connecting to an Azure Quantum workspace\\r\\nas specified by the resource ID and location of the workspace or by a combination of\\r\\nsubscription ID, resource group name, workspace name, and location.\\r\\n\\r\\nIf the connection is successful, a list of the available Q# execution targets\\r\\nin the Azure Quantum workspace will be displayed.\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\nThe Azure Quantum workspace can be identified by resource ID:\\r\\n\\r\\n- `resourceId=<string>`: The resource ID of the Azure Quantum workspace.\\r\\nThis can be obtained from the workspace page in the Azure portal. The `resourceId=` prefix\\r\\nis optional for this parameter, as long as the resource ID is valid.\\r\\n\\r\\nAlternatively, it can be identified by subscription ID, resource group name, and workspace name:\\r\\n\\r\\n- `subscription=<string>`: The Azure subscription ID for the Azure Quantum workspace.\\r\\n- `resourceGroup=<string>`: The Azure resource group name for the Azure Quantum workspace.\\r\\n- `workspace=<string>`: The name of the Azure Quantum workspace.\\r\\n\\r\\nAlong with the identifiers above, a valid location is required.\\r\\n\\r\\n- `location=<string>`: The Azure region where the Azure Quantum workspace is provisioned.\\r\\nThis may be specified as a region name such as `\\\"East US\\\"` or a location name such as `\\\"eastus\\\"`.\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- `storage=<string>`: The connection string to the Azure storage\\r\\naccount. Required if the specified Azure Quantum workspace was not linked to a storage\\r\\naccount at workspace creation time.\\r\\n- `credential=<CredentialType>`: The type of credentials to use to authenticate with Azure.\\r\\nNOTE: to authenticate we leverage the [Azure Identity library](https://docs.microsoft.com/dotnet/api/overview/azure/identity-readme), \\r\\nbased on this parameter we will create an instance of a Credential Class. \\r\\nPossible options are:\\r\\n  * [Environment](https://docs.microsoft.com/dotnet/api/azure.identity.environmentcredential):\\r\\n     Authenticates a service principal or user via credential information specified in environment variables.\\r\\n  * [ManagedIdentity](https://docs.microsoft.com/dotnet/api/azure.identity.managedidentitycredential):\\r\\n     Authenticates the managed identity of an azure resource.\\r\\n  * [CLI](https://docs.microsoft.com/dotnet/api/azure.identity.azureclicredential):\\r\\n     Authenticate in a development environment with the Azure CLI.\\r\\n  * [SharedToken](https://docs.microsoft.com/dotnet/api/azure.identity.sharedtokencachecredential):\\r\\n     Authenticate using tokens in the local cache shared between Microsoft applications.\\r\\n  * [VisualStudio](https://docs.microsoft.com/dotnet/api/azure.identity.visualstudiocredential):\\r\\n     Authenticate using data from Visual Studio.\\r\\n  * [VisualStudioCode](https://docs.microsoft.com/dotnet/api/azure.identity.visualstudiocodecredential):\\r\\n     Authenticate in a development environment with Visual Studio Code.\\r\\n  * [Interactive](https://docs.microsoft.com/dotnet/api/azure.identity.interactivebrowsercredential):\\r\\n     Opens a new browser window to interactively authenticate a user \\r\\n     and obtain an access token.\\r\\n  * [DeviceCode](https://docs.microsoft.com/dotnet/api/azure.identity.devicecodecredential):\\r\\n     Authenticates a user using the device code flow to obtain an access token.\\r\\nIf not provided, it will try each credential type in order and pick the first one that can\\r\\nsuccesfully authenticate with Azure.\\r\\n\\r\\n#### Possible errors\\r\\n\\r\\n- `WorkspaceNotFound`: No Azure Quantum workspace was found that matches the specified criteria.\\r\\n- `AuthenticationFailed`: Failed to authenticate to the specified Azure Quantum workspace.\\r\\n                    \",\"Remarks\":null,\"Examples\":[\"\\r\\nConnect to an Azure Quantum workspace using its resource ID to the 'West Us' region:\\r\\n```\\r\\nIn []: %azure.connect \\\"/subscriptions/.../Microsoft.Quantum/Workspaces/WORKSPACE_NAME\\\" location=\\\"West US\\\"\\r\\nOut[]: Connected to Azure Quantum workspace WORKSPACE_NAME in location westus.\\r\\n        <list of Q# execution targets available in the Azure Quantum workspace>\\r\\n```\\r\\n                        \",\"\\r\\nConnect to an Azure Quantum workspace using its resource ID, a storage account connection string, and a location:\\r\\n```\\r\\nIn []: %azure.connect resourceId=\\\"/subscriptions/.../Microsoft.Quantum/Workspaces/WORKSPACE_NAME\\\"\\r\\n                      storage=\\\"STORAGE_ACCOUNT_CONNECTION_STRING\\\"\\r\\n                      location=\\\"East US\\\"\\r\\nOut[]: Connected to Azure Quantum workspace WORKSPACE_NAME in location eastus.\\r\\n        <list of Q# execution targets available in the Azure Quantum workspace>\\r\\n```\\r\\n                        \",\"\\r\\nConnect to an Azure Quantum workspace using individual subscription ID, resource group name, using a browser to prompt for user credentials with Azure:\\r\\n```\\r\\nIn []: %azure.connect subscription=\\\"SUBSCRIPTION_ID\\\"\\r\\n                      resourceGroup=\\\"RESOURCE_GROUP_NAME\\\"\\r\\n                      workspace=\\\"WORKSPACE_NAME\\\"\\r\\n                      location=\\\"West US\\\"\\r\\n                      credential=\\\"interactive\\\"\\r\\nOut[]: Connected to Azure Quantum workspace WORKSPACE_NAME in location westus.\\r\\n        <list of Q# execution targets available in the Azure Quantum workspace>\\r\\n```\\r\\n                        \",\"\\r\\nPrint information about the currently-connected Azure Quantum workspace:\\r\\n```\\r\\nIn []: %azure.connect\\r\\nOut[]: Connected to Azure Quantum workspace WORKSPACE_NAME in location westus.\\r\\n        <list of Q# execution targets available in the Azure Quantum workspace>\\r\\n```\\r\\n                        \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.AzureClient\"},{\"Name\":\"%azure.execute\",\"Documentation\":{\"Summary\":\"Submits a job to an Azure Quantum workspace and waits for completion.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for submitting a Q# operation or function\\r\\nto be run on the specified target in the current Azure Quantum workspace.\\r\\nThe command waits a specified amount of time for the job to complete before returning.\\r\\n\\r\\nThe Azure Quantum workspace must have been previously initialized\\r\\nusing the [`%azure.connect` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.connect),\\r\\nand an execution target for the job must have been specified using the\\r\\n[`%azure.target` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.target).\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\n- Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\\r\\nor function name that has been defined either in the notebook or in a Q# file in the same folder.\\r\\n- Arguments for the Q# operation or function must also be specified as `key=value` pairs.\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- `jobName=<string>`: Friendly name to identify this job. If not specified,\\r\\nthe Q# operation or function name will be used as the job name.\\r\\n- `jobParams=<JSON key:value pairs>`: Provider-specific job parameters\\r\\nexpressed in JSON as one or more `key`:`value` pairs to be passed to the execution target. Values must be strings.\\r\\n- `shots=<integer>` (default=500): Number of times to repeat execution of the\\r\\nspecified Q# operation or function.\\r\\n- `timeout=<integer>` (default=30): Time to wait (in seconds) for job completion\\r\\nbefore the magic command returns.\\r\\n- `poll=<integer>` (default=5): Interval (in seconds) to poll for\\r\\njob status while waiting for job execution to complete.\\r\\n\\r\\n#### Possible errors\\r\\n\\r\\n- `NotConnected`: Not connected to any Azure Quantum workspace.\\r\\n- `NoTarget`: No execution target has been configured for Azure Quantum job submission.\\r\\n- `NoOperationName`: No Q# operation name was specified for Azure Quantum job submission.\\r\\n- `InvalidTarget`: The specified execution target is not valid for Q# job submission in the current Azure Quantum workspace.\\r\\n- `UnrecognizedOperationName`: The specified Q# operation name was not recognized.\\r\\n- `InvalidEntryPoint`: The specified Q# operation cannot be used as an entry point for Azure Quantum job submission.\\r\\n- `JobSubmissionFailed`: Failed to submit the job to the Azure Quantum workspace.\\r\\n- `JobNotCompleted`: The specified Azure Quantum job has not yet completed.\\r\\n- `JobOutputDownloadFailed`: Failed to download results for the specified Azure Quantum job.\\r\\n- `JobFailedOrCancelled`: The specified Azure Quantum job failed or was cancelled.\\r\\n                    \",\"Remarks\":null,\"Examples\":[\"\\r\\nRun a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`\\r\\non the active target in the current Azure Quantum workspace:\\r\\n```\\r\\nIn []: %azure.execute MyOperation a=5 b=10\\r\\nOut[]: Submitting MyOperation to target provider.qpu...\\r\\n       Job successfully submitted for 500 shots.\\r\\n          Job name: MyOperation\\r\\n          Job ID: <Azure Quantum job ID>\\r\\n       Waiting up to 30 seconds for Azure Quantum job to complete...\\r\\n       [1:23:45 PM] Current job status: Waiting\\r\\n       [1:23:50 PM] Current job status: Executing\\r\\n       [1:23:55 PM] Current job status: Succeeded\\r\\n       <detailed results of completed job>\\r\\n```\\r\\n                        \",\"\\r\\nRun a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`\\r\\non the active target in the current Azure Quantum workspace,\\r\\nspecifying a custom job name, number of shots, timeout, polling interval, and provider-specific job parameters:\\r\\n```\\r\\nIn []: %azure.submit MyOperation a=5 b=10 jobName=\\\"My job\\\" shots=100 timeout=60 poll=10 jobParams={\\\"Key1\\\":\\\"Val1\\\",\\\"Key2\\\":\\\"Val2\\\"}\\r\\nOut[]: Submitting MyOperation to target provider.qpu...\\r\\n       Job successfully submitted for 100 shots.\\r\\n          Job name: My job\\r\\n          Job ID: <Azure Quantum job ID>\\r\\n       Waiting up to 60 seconds for Azure Quantum job to complete...\\r\\n       [1:23:45 PM] Current job status: Waiting\\r\\n       [1:23:55 PM] Current job status: Waiting\\r\\n       [1:24:05 PM] Current job status: Executing\\r\\n       [1:24:15 PM] Current job status: Succeeded\\r\\n       <detailed results of completed job>\\r\\n```\\r\\n                        \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.AzureClient\"},{\"Name\":\"%azure.jobs\",\"Documentation\":{\"Summary\":\"Displays a list of jobs in the current Azure Quantum workspace.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for displaying the list of jobs in the current \\r\\nAzure Quantum workspace, optionally filtering the list to jobs which\\r\\nhave an ID, name, or target containing the provided filter parameter.\\r\\n\\r\\nThe Azure Quantum workspace must have been previously initialized\\r\\nusing the [`%azure.connect` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.connect).\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- A string to filter the list of jobs. Jobs which have an ID, name, or target\\r\\ncontaining the provided filter parameter will be displayed. If not specified,\\r\\nno job is filtered.\\r\\n- `count=<integer>` (default=30): The max number of jobs to return.\\r\\n\\r\\n#### Possible errors\\r\\n\\r\\n- `NotConnected`: Not connected to any Azure Quantum workspace.\\r\\n                    \",\"Remarks\":null,\"Examples\":[\"\\r\\nGet the list of jobs:\\r\\n```\\r\\nIn []: %azure.jobs\\r\\nOut[]: <detailed status of all recent jobs in the workspace>\\r\\n```\\r\\n                        \",\"\\r\\nGet the list of jobs whose ID, name, or target contains \\\"My job\\\":\\r\\n```\\r\\nIn []: %azure.jobs \\\"My job\\\"\\r\\nOut[]: <detailed status of matching jobs in the workspace>\\r\\n```\\r\\n                        \",\"\\r\\nGet the list of jobs whose ID, name, or target contains \\\"My job\\\", limit it to at most 100 jobs:\\r\\n```\\r\\nIn []: %azure.jobs \\\"My job\\\" count=100\\r\\nOut[]: <detailed status of at most 100 matching jobs in the workspace>\\r\\n```\\r\\n                        \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.AzureClient\"},{\"Name\":\"%azure.output\",\"Documentation\":{\"Summary\":\"Displays results for a job in the current Azure Quantum workspace.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for displaying results for a job in the current \\r\\nAzure Quantum workspace.\\r\\nThe job execution must already be completed in order to display\\r\\nresults.\\r\\n\\r\\nThe Azure Quantum workspace must have been previously initialized\\r\\nusing the [`%azure.connect` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.connect.\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- The job ID for which to display results. If not specified, the job ID from\\r\\nthe most recent call to [`%azure.submit`](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.submit\\r\\nor [`%azure.execute`](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.execute will be used.\\r\\n\\r\\n#### Possible errors\\r\\n\\r\\n- `NotConnected`: Not connected to any Azure Quantum workspace.\\r\\n- `JobNotFound`: No job with the given ID was found in the current Azure Quantum workspace.\\r\\n- `JobNotCompleted`: The specified Azure Quantum job has not yet completed.\\r\\n- `JobOutputDownloadFailed`: Failed to download results for the specified Azure Quantum job.\\r\\n- `JobFailedOrCancelled`: The specified Azure Quantum job failed or was cancelled.\\r\\n                    \",\"Remarks\":null,\"Examples\":[\"\\r\\nGet results of a specific job:\\r\\n```\\r\\nIn []: %azure.output JOB_ID\\r\\nOut[]: <detailed results of specified job>\\r\\n```\\r\\n                        \",\"\\r\\nGet results of the most recently submitted job:\\r\\n```\\r\\nIn []: %azure.output\\r\\nOut[]: <detailed results of most recently submitted job>\\r\\n```\\r\\n                        \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.AzureClient\"},{\"Name\":\"%azure.quotas\",\"Documentation\":{\"Summary\":\"Displays a list of quotas for the current Azure Quantum workspace.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for displaying quota information for the current \\r\\nAzure Quantum workspace.\\r\\n\\r\\nThe Azure Quantum workspace must have been previously initialized\\r\\nusing the [`%azure.connect` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.connect).\\r\\n                        \\r\\n#### Possible errors\\r\\n\\r\\n- `NotConnected`: Not connected to any Azure Quantum workspace.\\r\\n                    \",\"Remarks\":null,\"Examples\":[\"\\r\\nGet the list of quotas:\\r\\n```\\r\\nIn []: %azure.quotas\\r\\nOut[]: <quota information for the workspace>\\r\\n```\\r\\n                        \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.AzureClient\"},{\"Name\":\"%azure.status\",\"Documentation\":{\"Summary\":\"Displays status for a job in the current Azure Quantum workspace.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for displaying status for a job in the current \\r\\nAzure Quantum workspace.\\r\\n\\r\\nThe Azure Quantum workspace must have been previously initialized\\r\\nusing the [`%azure.connect` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.connect).\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- The job ID for which to display status. If not specified, the job ID from\\r\\nthe most recent call to [`%azure.submit`](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.submit)\\r\\nor [`%azure.execute`](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.execute) will be used.\\r\\n\\r\\n#### Possible errors\\r\\n\\r\\n- `NotConnected`: Not connected to any Azure Quantum workspace.\\r\\n- `JobNotFound`: No job with the given ID was found in the current Azure Quantum workspace.\\r\\n                    \",\"Remarks\":null,\"Examples\":[\"\\r\\nGet the status of a specific job:\\r\\n```\\r\\nIn []: %azure.status JOB_ID\\r\\nOut[]: <detailed status of specified job>\\r\\n```\\r\\n                        \",\"\\r\\nGet the status of the most recently submitted job:\\r\\n```\\r\\nIn []: %azure.status\\r\\nOut[]: <detailed status of most recently submitted job>\\r\\n```\\r\\n                        \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.AzureClient\"},{\"Name\":\"%azure.submit\",\"Documentation\":{\"Summary\":\"Submits a job to an Azure Quantum workspace.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for submitting a Q# operation or function\\r\\nto be run on the specified target in the current Azure Quantum workspace.\\r\\nThe command returns immediately after the job is submitted.\\r\\n\\r\\nThe Azure Quantum workspace must have been previously initialized\\r\\nusing the [`%azure.connect` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.connect),\\r\\nand an execution target for the job must have been specified using the\\r\\n[`%azure.target` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.target).\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\n- Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\\r\\nor function name that has been defined either in the notebook or in a Q# file in the same folder.\\r\\n- Arguments for the Q# operation or function must also be specified as `key=value` pairs.\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- `jobName=<string>`: Friendly name to identify this job. If not specified,\\r\\nthe Q# operation or function name will be used as the job name.\\r\\n- `jobParams=<JSON key:value pairs>`: Provider-specific job parameters\\r\\nexpressed in JSON as one or more `key`:`value` pairs to be passed to the execution target. Values must be strings.\\r\\n- `shots=<integer>` (default=500): Number of times to repeat execution of the\\r\\nspecified Q# operation or function.\\r\\n\\r\\n#### Possible errors\\r\\n\\r\\n- `NotConnected`: Not connected to any Azure Quantum workspace.\\r\\n- `NoTarget`: No execution target has been configured for Azure Quantum job submission.\\r\\n- `NoOperationName`: No Q# operation name was specified for Azure Quantum job submission.\\r\\n- `InvalidTarget`: The specified execution target is not valid for Q# job submission in the current Azure Quantum workspace.\\r\\n- `UnrecognizedOperationName`: The specified Q# operation name was not recognized.\\r\\n- `InvalidEntryPoint`: The specified Q# operation cannot be used as an entry point for Azure Quantum job submission.\\r\\n- `JobSubmissionFailed`: Failed to submit the job to the Azure Quantum workspace.\\r\\n                    \",\"Remarks\":null,\"Examples\":[\"\\r\\nSubmit a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`\\r\\nfor execution on the active target in the current Azure Quantum workspace:\\r\\n```\\r\\nIn []: %azure.submit MyOperation a=5 b=10\\r\\nOut[]: Submitting MyOperation to target provider.qpu...\\r\\n       Job successfully submitted for 500 shots.\\r\\n          Job name: MyOperation\\r\\n          Job ID: <Azure Quantum job ID>\\r\\n       <detailed properties of submitted job>\\r\\n```\\r\\n                        \",\"\\r\\nSubmit a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`\\r\\nfor execution on the active target in the current Azure Quantum workspace,\\r\\nspecifying a custom job name, number of shots, and provider-specific job parameters:\\r\\n```\\r\\nIn []: %azure.submit MyOperation a=5 b=10 jobName=\\\"My job\\\" shots=100 jobParams={\\\"Key1\\\":\\\"Val1\\\",\\\"Key2\\\":\\\"Val2\\\"}\\r\\nOut[]: Submitting MyOperation to target provider.qpu...\\r\\n       Job successfully submitted for 100 shots.\\r\\n          Job name: My job\\r\\n          Job ID: <Azure Quantum job ID>\\r\\n       <detailed properties of submitted job>\\r\\n```\\r\\n                        \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.AzureClient\"},{\"Name\":\"%azure.target\",\"Documentation\":{\"Summary\":\"Sets or displays the active execution target for Q# job submission in an Azure Quantum workspace.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for specifying or displaying the execution target for Q# job submission\\r\\nin an Azure Quantum workspace.\\r\\n\\r\\nThe Azure Quantum workspace must have been previously initialized\\r\\nusing the [`%azure.connect` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.connect)\\r\\nmagic command. The specified execution target must be available in the workspace and support execution of Q# programs.\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- The target ID to set as the active execution target for Q# job submission. If not specified,\\r\\nthe currently active execution target is displayed.\\r\\n\\r\\n#### Possible errors\\r\\n\\r\\n- `NotConnected`: Not connected to any Azure Quantum workspace.\\r\\n- `InvalidTarget`: The specified execution target is not valid for Q# job submission in the current Azure Quantum workspace.\\r\\n- `NoTarget`: No execution target has been configured for Azure Quantum job submission.\\r\\n                    \",\"Remarks\":null,\"Examples\":[\"\\r\\nSet the current target for Q# job submission to `provider.qpu`:\\r\\n```\\r\\nIn []: %azure.target provider.qpu\\r\\nOut[]: Loading package Microsoft.Quantum.Providers.Provider and dependencies...\\r\\n       Active target is now provider.qpu\\r\\n       <detailed properties of active execution target>\\r\\n```\\r\\n                        \",\"\\r\\nDisplay the current target and all available targets in the current Azure Quantum workspace:\\r\\n```\\r\\nIn []: %azure.target\\r\\nOut[]: Current execution target: provider.qpu\\r\\n       Available execution targets: provider.qpu, provider.simulator\\r\\n       <detailed properties of active execution target>\\r\\n```\\r\\n                        \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.AzureClient\"},{\"Name\":\"%config\",\"Documentation\":{\"Summary\":\"Allows setting or querying configuration options.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for setting or querying\\r\\nconfiguration options used to control the behavior of the\\r\\nIQ# kernel (such as state visualization options). It also\\r\\nallows for saving those options to a JSON file in the current\\r\\nworking directory (using the `--save` option).\\r\\n\\r\\n#### Configuration settings\\r\\n\\r\\n**`dump.basisStateLabelingConvention`**\\r\\n\\r\\n**Value:** `\\\"LittleEndian\\\"` (default), `\\\"BigEndian\\\"`, or `\\\"Bitstring\\\"`\\r\\n\\r\\nThe convention to be used when labeling computational\\r\\nbasis states in output from callables such as `DumpMachine` or `DumpRegister`.\\r\\n\\r\\n**`dump.truncateSmallAmplitudes`**\\r\\n\\r\\n**Value:** `true` or `false` (default)\\r\\n\\r\\nHides basis states of a state vector whose measurement probabilities\\r\\n(i.e., squared amplitudes) are smaller than a particular threshold, as determined by\\r\\nthe `dump.truncationThreshold` setting.\\r\\n\\r\\n**`dump.truncationThreshold`**\\r\\n\\r\\n**Value:** floating point number such as `0.001` or `1E-8` (default `1E-10`)\\r\\n\\r\\nIf `dump.truncateSmallAmplitudes` is set to `true`, determines the\\r\\nthreshold for measurement probabilities (i.e., squared amplitudes) below which to hide the display\\r\\nof basis states of a state vector.\\r\\n\\r\\n**`dump.phaseDisplayStyle`**\\r\\n\\r\\n**Value:** `\\\"ArrowOnly\\\"` (default), `\\\"NumberOnly\\\"`, `\\\"ArrowAndNumber\\\"`, or `\\\"None\\\"`\\r\\n\\r\\nConfigures the phase visualization style in output from callables such as\\r\\n`DumpMachine` or `DumpRegister`. Supports displaying phase as arrows, numbers (in radians), both, or neither.\\r\\n\\r\\n**`dump.measurementDisplayStyle`**\\r\\n\\r\\n**Value:** `\\\"NumberOnly\\\"`, `\\\"BarOnly\\\"`, `\\\"BarAndNumber\\\"` (default), or `\\\"None\\\"`\\r\\n\\r\\nConfigures the measurement probability visualization style in output of callables such as \\r\\n`DumpMachine` or `DumpRegister`. Supports displaying measurement probability as progress bars, numbers, both,\\r\\nor neither. \\r\\n\\r\\n**`dump.measurementDisplayPrecision`**\\r\\n\\r\\n**Value:** non-negative integer (default `4`)\\r\\n\\r\\nSets the precision of the measurement probability displayed as a percentage when\\r\\n`dump.measurementDisplayStyle` is set to `\\\"NumberOnly\\\"` or `\\\"BarAndNumber\\\"`.\\r\\n\\r\\n**`dump.measurementDisplayHistogram`**\\r\\n\\r\\n**Value:** `true` or `false` (default)\\r\\n\\r\\nIf `dump.measurementDisplayHistogram` is set to `true`, displays an interactive\\r\\nhistogram representation of the state of the simulator underneath the static state visualization.\\r\\n\\r\\n**`dump.plainTextOnly`**\\r\\n\\r\\n**Value:** `true` or `false` (default)\\r\\n\\r\\nForces plain-text output from callables such as `DumpMachine` and `DumpRegister`, even\\r\\nwhen using an HTML-enabled client such as Jupyter Notebook.\\r\\n\\r\\n**`trace.defaultDepth`**\\r\\n\\r\\n**Value:** positive integer (default `1`)\\r\\n\\r\\nConfigures the default depth used in the `%trace` command for visualizing Q# operations.\\r\\n\\r\\n**`trace.style`**\\r\\n\\r\\n**Value:** `\\\"Default\\\"` (default), `\\\"BlackAndWhite\\\"`, or `\\\"Inverted\\\"`\\r\\n\\r\\nConfigures the default style used in generating the visualization of Q# operations with the `%trace` command.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nPrint a list of all currently set configuration options:\\r\\n```\\r\\nIn []: %config\\r\\nOut[]: Configuration key                 Value\\r\\n       --------------------------------- -----------\\r\\n       dump.basisStateLabelingConvention \\\"BigEndian\\\"\\r\\n       dump.truncateSmallAmplitudes      true\\r\\n```\\r\\n                    \",\"\\r\\nConfigure the `DumpMachine` and `DumpRegister` callables\\r\\nto use big-endian convention:\\r\\n```\\r\\nIn []: %config dump.basisStateLabelingConvention=\\\"BigEndian\\\"\\r\\nOut[]: \\\"BigEndian\\\"\\r\\n```\\r\\n                    \",\"\\r\\nSave current configuration options to `.iqsharp-config.json`\\r\\nin the current working directory:\\r\\n```\\r\\nIn []: %config --save\\r\\nOut[]: \\r\\n```\\r\\nNote that options saved this way will be applied automatically\\r\\nthe next time a notebook in the current working\\r\\ndirectory is loaded.\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%debug\",\"Documentation\":{\"Summary\":\"Steps through the execution of a given Q# operation or function.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for stepping through the execution of a given Q# operation\\r\\nor function using the QuantumSimulator.\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\n- Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\\r\\nor function name that has been defined either in the notebook or in a Q# file in the same folder.\\r\\n- Arguments for the Q# operation or function must also be specified as `key=value` pairs.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nStep through the execution of a Q# operation defined as `operation MyOperation() : Result`:\\r\\n```\\r\\nIn []: %debug MyOperation\\r\\nOut[]: <interactive HTML for stepping through the operation>\\r\\n```\\r\\n                    \",\"\\r\\nStep through the execution of a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`:\\r\\n```\\r\\nIn []: %debug MyOperation a=5 b=10\\r\\nOut[]: <interactive HTML for stepping through the operation>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%estimate\",\"Documentation\":{\"Summary\":\"Runs a given function or operation on the ResourcesEstimator target machine.\",\"Full\":null,\"Description\":\"\\r\\nThe ResourcesEstimator estimates statistics about how many resources the given\\r\\noperation needs for execution. The resources it calculates include:\\r\\n\\r\\n- Counts for each primitive operation\\r\\n- Depth (lower bound for the T-gate depth of the quantum circuit)\\r\\n- Width (lower bound for the maximum number of qubits used for the computation)\\r\\n\\r\\nSee the [ResourcesEstimator user guide](https://docs.microsoft.com/azure/quantum/user-guide/machines/resources-estimator) to learn more.\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\n- Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\\r\\nor function name that has been defined either in the notebook or in a Q# file in the same folder.\\r\\n- Arguments for the Q# operation or function must also be specified as `key=value` pairs.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nEstimate resources for a Q# operation defined as `operation MyOperation() : Result`:\\r\\n```\\r\\nIn []: %estimate MyOperation\\r\\nOut[]: Metric           Sum     \\r\\n       ---------------- ----\\r\\n       CNOT             0\\r\\n       QubitClifford    4\\r\\n       R                0\\r\\n       Measure          8\\r\\n       T                0\\r\\n       Depth            0\\r\\n       Width            4\\r\\n       BorrowedWidth    0\\r\\n```\\r\\n                    \",\"\\r\\nEstimate resources for a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`:\\r\\n```\\r\\nIn []: %estimate MyOperation a=5 b=10\\r\\nOut[]: Metric           Sum     \\r\\n       ---------------- ----\\r\\n       CNOT             0\\r\\n       QubitClifford    4\\r\\n       R                0\\r\\n       Measure          8\\r\\n       T                0\\r\\n       Depth            0\\r\\n       Width            4\\r\\n       BorrowedWidth    0\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%experimental.build_info\",\"Documentation\":{\"Summary\":\"Reports build info for the experimental simulators.\",\"Full\":null,\"Description\":\"\\r\\n> **⚠ WARNING:** This magic command is **experimental**,\\r\\n> is not supported, and may be removed from future versions without notice.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nReturn the build info for experimental simulators:\\r\\n```\\r\\nIn []: %experimental.build_info\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%experimental.noise_model\",\"Documentation\":{\"Summary\":\"Gets, sets, saves, or loads a noise model used in simulating quantum operations.\",\"Full\":null,\"Description\":\"\\r\\n> **⚠ WARNING:** This magic command is **experimental**,\\r\\n> is not supported, and may be removed from future versions without notice.\\r\\n\\r\\nThis magic command allows accessing or modifying the noise model used by\\r\\nthe `%experimental.simulate_noise` magic command.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nReturn the currently set noise model:\\r\\n```\\r\\nIn []: %experimental.noise_model\\r\\n```\\r\\n                    \",\"\\r\\n                        Return the built-in noise model with a given name:\\r\\n                        ```\\r\\n                        In []: %experimental.noise_model --get-by-name ideal\\r\\n                        ```\\r\\n                    \",\"\\r\\nSets the noise model to a built-in named noise model:\\r\\n```\\r\\nIn []: %experimental.noise_model --load-by-name ideal_stabilizer\\r\\n```\\r\\n                    \",\"\\r\\nSet the noise model to a noise model given as JSON:\\r\\n```\\r\\nIn []: %experimental.noise_model { ... }\\r\\n```\\r\\n                    \",\"\\r\\nSave the current noise model to a JSON file named\\r\\n`noise-model.json`:\\r\\n```\\r\\nIn []: %experimental.noise_model --save noise-model.json\\r\\n```\\r\\n                    \",\"\\r\\nLoad the noise model stored in `noise-model.json`,\\r\\nmaking it the active noise model:\\r\\n```\\r\\nIn []: %experimental.noise_model --load noise-model.json\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%experimental.simulate_noise\",\"Documentation\":{\"Summary\":\"Runs a given function or operation on the OpenSystemsSimulator target machine.\",\"Full\":null,\"Description\":\"\\r\\n> **⚠ WARNING:** This magic command is **experimental**,\\r\\n> is not supported, and may be removed from future versions without notice.\\r\\n\\r\\nThis magic command allows executing a given function or operation\\r\\non the OpenSystemsSimulator target, simulating how that function or operation\\r\\nwill perform when run on noisy quantum hardware.\\r\\n\\r\\n#### See also\\r\\n\\r\\n- [`%config`](https://docs.microsoft.com/qsharp/api/iqsharp-magic/config)\\r\\n- [`%experimental.noise_model`](https://docs.microsoft.com/qsharp/api/iqsharp-magic/experimental.noise_model)\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\n- Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\\r\\nor function name that has been defined either in the notebook or in a Q# file in the same folder.\\r\\n- Arguments for the Q# operation or function must also be specified as `key=value` pairs.\\r\\n\\r\\n#### Remarks\\r\\n\\r\\nThe behavior of this magic command can be controlled through the `%experimental.noise_model` magic command,\\r\\nand the `opensim.nQubits` and `opensim.representation` configuration settings.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nSimulate a Q# operation defined as `operation MyOperation() : Result`:\\r\\n```\\r\\nIn []: %simulate MyOperation\\r\\nOut[]: <return value of the operation>\\r\\n```\\r\\n                    \",\"\\r\\nSimulate a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`:\\r\\n```\\r\\nIn []: %simulate MyOperation a=5 b=10\\r\\nOut[]: <return value of the operation>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%lsmagic\",\"Documentation\":{\"Summary\":\"Returns a list of all currently available magic commands.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command lists all of the magic commands available in the IQ# kernel,\\r\\nas well as those defined in any packages that have been loaded in the current\\r\\nsession via the [`%package` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/package).\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nDisplay the list of available magic commands:\\r\\n```\\r\\nIn []: %lsmagic\\r\\nOut[]: <detailed list of all available magic commands>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%lsopen\",\"Documentation\":{\"Summary\":\"Lists currently opened namespaces and their aliases.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command lists any namespaces that have been made\\r\\navailable using `open` statements, along with any aliases\\r\\nthat may have been assigned to those namespaces.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nPrint a list of all currently opened namespaces:\\r\\n```\\r\\nIn []: %lsopen\\r\\nOut[]: Namespace                     Alias\\r\\n       ----------------------------- ----\\r\\n       Microsoft.Quantum.Canon\\r\\n       Microsoft.Quantum.Diagnostics Diag\\r\\n       Microsoft.Quantum.Intrinsic\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%package\",\"Documentation\":{\"Summary\":\"Provides the ability to load a NuGet package.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for loading a NuGet package into the current IQ# kernel process.\\r\\nThe package must be available on the system's list of NuGet sources, which typically includes nuget.org.\\r\\nQ# operations, functions, and user-defined types defined in the loaded package,\\r\\nalong with functionality such as magic commands and result encoders,\\r\\nwill automatically become available for use in the current session.\\r\\n\\r\\nThe package can be specified by name only, or by name and version (using `name::version` syntax).\\r\\n\\r\\nIf no version is specified:\\r\\n\\r\\n- For packages that are part of the Microsoft Quantum Development Kit, IQ# will attempt to\\r\\nobtain the version of the package that matches the current IQ# version.\\r\\n- For other packages, IQ# will attempt to obtain the most recent version of the package.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nLoad the `Microsoft.Quantum.MachineLearning` package into the current IQ# session:\\r\\n```\\r\\nIn []: %package Microsoft.Quantum.MachineLearning\\r\\nOut[]: Adding package Microsoft.Quantum.MachineLearning: done!\\r\\n       <list of all loaded packages and versions>\\r\\n```\\r\\n                    \",\"\\r\\nLoad a specific version of the `Microsoft.Quantum.Katas` package into the current IQ# session:\\r\\n```\\r\\nIn []: %package Microsoft.Quantum.Katas::0.28.291394 Adding package Microsoft.Quantum.Katas::0.11.2006.403: done!\\r\\n       <list of all loaded packages and versions>\\r\\n```\\r\\n                    \",\"\\r\\nView the list of all packages that have been loaded into the current IQ# session:\\r\\n```\\r\\nIn []: %package\\r\\nOut[]: <list of all loaded packages and versions>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%performance\",\"Documentation\":{\"Summary\":\"Reports current performance metrics for this kernel.\",\"Full\":null,\"Description\":\"\\r\\nReports various performance metrics for the current IQ# kernel process, including:\\r\\n\\r\\n- Managed RAM usage\\r\\n- Total RAM usage\\r\\n- Virtual memory size\\r\\n- User time\\r\\n- Total time\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nDisplay performance metrics for the current IQ# kernel process:\\r\\n```\\r\\nIn []: %performance\\r\\nOut[]: Metric                        Value\\r\\n       ----------------------------  -------------\\r\\n       Managed RAM usage (bytes)     4.985 MiB\\r\\n       Total RAM usage (bytes)       54.543 MiB\\r\\n       Virtual memory size (bytes)   2.005 TiB\\r\\n       User time                     00:00:01.109\\r\\n       Total time                    00:00:01.437\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%project\",\"Documentation\":{\"Summary\":\"Provides the ability to view or add Q# project references.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for adding references to Q# projects to be compiled and loaded\\r\\ninto the current IQ# session.\\r\\n\\r\\nThe command accepts a single argument, which is the path to a .csproj file to be loaded.\\r\\nThe .csproj file must reference the Microsoft.Quantum.Sdk. The provided path may be either\\r\\nan absolute path or a path relative to the current workspace root folder (usually the\\r\\nfolder containing the current .ipynb file). The project file will be added to the session\\r\\nand then the workspace will be reloaded, which will automatically load any downstream\\r\\npackages or projects referenced by the specified .csproj file and will recompile all\\r\\nassociated .qs source files.\\r\\n\\r\\nIf no argument is provided, the command simply returns the list of projects loaded in\\r\\nthe current IQ# session.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nAdd a reference to the `C:\\\\Projects\\\\MyProject.csproj` Q# project into the current IQ# session:\\r\\n```\\r\\nIn []: %project C:\\\\Projects\\\\MyProject.csproj\\r\\nOut[]: Loading project C:\\\\Projects\\\\MyProject.csproj and dependencies...\\r\\n       <list of all loaded Q# project references>\\r\\n```\\r\\n                    \",\"\\r\\nView the list of all Q# project references that have been loaded into the current IQ# session:\\r\\n```\\r\\nIn []: %project\\r\\nOut[]: <list of all loaded Q# project references>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%simulate\",\"Documentation\":{\"Summary\":\"Runs a given function or operation on the QuantumSimulator target machine.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows executing a given function or operation on the QuantumSimulator, \\r\\nwhich performs a full-state simulation of the given function or operation\\r\\nand prints the resulting return value.\\r\\n\\r\\nSee the [QuantumSimulator user guide](https://docs.microsoft.com/azure/quantum/user-guide/machines/full-state-simulator) to learn more.\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\n- Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\\r\\nor function name that has been defined either in the notebook or in a Q# file in the same folder.\\r\\n- Arguments for the Q# operation or function must also be specified as `key=value` pairs.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nSimulate a Q# operation defined as `operation MyOperation() : Result`:\\r\\n```\\r\\nIn []: %simulate MyOperation\\r\\nOut[]: <return value of the operation>\\r\\n```\\r\\n                    \",\"\\r\\nSimulate a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`:\\r\\n```\\r\\nIn []: %simulate MyOperation a=5 b=10\\r\\nOut[]: <return value of the operation>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%toffoli\",\"Documentation\":{\"Summary\":\"Runs a given function or operation on the ToffoliSimulator target machine.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows executing a given function or operation on the ToffoliSimulator, \\r\\nwhich performs a simulation of the given function or operation in which the state is always\\r\\na simple product state in the computational basis, and prints the resulting return value.\\r\\n\\r\\nSee the [ToffoliSimulator user guide](https://docs.microsoft.com/azure/quantum/user-guide/machines/toffoli-simulator) to learn more.\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\n- Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\\r\\nor function name that has been defined either in the notebook or in a Q# file in the same folder.\\r\\n- Arguments for the Q# operation or function must also be specified as `key=value` pairs.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nUse the ToffoliSimulator to simulate a Q# operation\\r\\ndefined as `operation MyOperation() : Result`:\\r\\n```\\r\\nIn []: %toffoli MyOperation\\r\\nOut[]: <return value of the operation>\\r\\n```\\r\\n                    \",\"\\r\\nUse the ToffoliSimulator to simulate a Q# operation\\r\\ndefined as `operation MyOperation(a : Int, b : Int) : Result`:\\r\\n```\\r\\nIn []: %toffoli MyOperation a=5 b=10\\r\\nOut[]: <return value of the operation>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%trace\",\"Documentation\":{\"Summary\":\"Visualizes the execution path of the given operation.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command renders an HTML-based visualization of a runtime execution path of the\\r\\ngiven operation using the QuantumSimulator.\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\n- Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\\r\\nor function name that has been defined either in the notebook or in a Q# file in the same folder.\\r\\n- Arguments for the Q# operation or function must also be specified as `key=value` pairs.\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- `--depth=<integer>` (default=1): The depth at which to render operations along\\r\\nthe execution path.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nVisualize the execution path of a Q# operation defined as `operation MyOperation() : Result`:\\r\\n```\\r\\nIn []: %trace MyOperation\\r\\nOut[]: <HTML visualization of the operation>\\r\\n```\\r\\n                    \",\"\\r\\nVisualize the execution path of a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`:\\r\\n```\\r\\nIn []: %trace MyOperation a=5 b=10\\r\\nOut[]: <HTML visualization of the operation>\\r\\n```\\r\\n                    \",\"\\r\\nVisualize operations at depth 2 on the execution path of a Q# operation defined\\r\\nas `operation MyOperation() : Result`:\\r\\n```\\r\\nIn []: %trace MyOperation --depth=2\\r\\nOut[]: <HTML visualization of the operation>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%who\",\"Documentation\":{\"Summary\":\"Lists the Q# operations available in the current session.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command returns a list of Q# operations and functions that are available\\r\\nin the current IQ# session for use with magic commands such as `%simulate`\\r\\nand `%estimate`.\\r\\n\\r\\nThe list will include Q# operations and functions which have been defined interactively\\r\\nwithin cells in the current notebook (after the cells have been executed),\\r\\nas well as any Q# operations and functions defined within .qs files in the current folder.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nDisplay the list of Q# operations and functions available in the current session:\\r\\n```\\r\\nIn []: %who\\r\\nOut[]: <list of Q# operation and function names>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"},{\"Name\":\"%workspace\",\"Documentation\":{\"Summary\":\"Provides actions related to the current workspace.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for displaying and reloading the Q# operations and functions\\r\\ndefined within .qs files in the current folder.\\r\\n\\r\\nIf no parameters are provided, the command displays a list of Q# operations or functions\\r\\nwithin .qs files in the current folder which are available\\r\\nin the current IQ# session for use with magic commands such as `%simulate`\\r\\nand `%estimate`.\\r\\n\\r\\nThe command will also output any errors encountered while compiling the .qs files\\r\\nin the current folder.\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- `reload`: Causes the IQ# kernel to recompile all .qs files in the current folder.\\r\\n                \",\"Remarks\":null,\"Examples\":[\"\\r\\nDisplay the list of Q# operations and functions available in the current folder:\\r\\n```\\r\\nIn []: %workspace\\r\\nOut[]: <list of Q# operation and function names>\\r\\n```\\r\\n                    \",\"\\r\\nRecompile the .qs files in the current folder:\\r\\n```\\r\\nIn []: %workspace reload\\r\\nOut[]: <list of Q# operation and function names>\\r\\n```\\r\\n                    \"],\"SeeAlso\":null},\"AssemblyName\":\"Microsoft.Quantum.IQSharp.Kernel\"}]",
      "text/html": [
       "<table><thead><tr><th style=\"text-align: start;\">Name</th><th style=\"text-align: start;\">Summary</th><th style=\"text-align: start;\">Assembly</th></tr></thead><tbody><tr><td style=\"text-align: start;\">%azure.connect</td><td style=\"text-align: start;\">Connects to an Azure Quantum workspace or displays current connection status.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.AzureClient</td></tr><tr><td style=\"text-align: start;\">%azure.execute</td><td style=\"text-align: start;\">Submits a job to an Azure Quantum workspace and waits for completion.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.AzureClient</td></tr><tr><td style=\"text-align: start;\">%azure.jobs</td><td style=\"text-align: start;\">Displays a list of jobs in the current Azure Quantum workspace.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.AzureClient</td></tr><tr><td style=\"text-align: start;\">%azure.output</td><td style=\"text-align: start;\">Displays results for a job in the current Azure Quantum workspace.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.AzureClient</td></tr><tr><td style=\"text-align: start;\">%azure.quotas</td><td style=\"text-align: start;\">Displays a list of quotas for the current Azure Quantum workspace.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.AzureClient</td></tr><tr><td style=\"text-align: start;\">%azure.status</td><td style=\"text-align: start;\">Displays status for a job in the current Azure Quantum workspace.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.AzureClient</td></tr><tr><td style=\"text-align: start;\">%azure.submit</td><td style=\"text-align: start;\">Submits a job to an Azure Quantum workspace.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.AzureClient</td></tr><tr><td style=\"text-align: start;\">%azure.target</td><td style=\"text-align: start;\">Sets or displays the active execution target for Q# job submission in an Azure Quantum workspace.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.AzureClient</td></tr><tr><td style=\"text-align: start;\">%config</td><td style=\"text-align: start;\">Allows setting or querying configuration options.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%debug</td><td style=\"text-align: start;\">Steps through the execution of a given Q# operation or function.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%estimate</td><td style=\"text-align: start;\">Runs a given function or operation on the ResourcesEstimator target machine.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%experimental.build_info</td><td style=\"text-align: start;\">Reports build info for the experimental simulators.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%experimental.noise_model</td><td style=\"text-align: start;\">Gets, sets, saves, or loads a noise model used in simulating quantum operations.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%experimental.simulate_noise</td><td style=\"text-align: start;\">Runs a given function or operation on the OpenSystemsSimulator target machine.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%lsmagic</td><td style=\"text-align: start;\">Returns a list of all currently available magic commands.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%lsopen</td><td style=\"text-align: start;\">Lists currently opened namespaces and their aliases.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%package</td><td style=\"text-align: start;\">Provides the ability to load a NuGet package.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%performance</td><td style=\"text-align: start;\">Reports current performance metrics for this kernel.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%project</td><td style=\"text-align: start;\">Provides the ability to view or add Q# project references.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%simulate</td><td style=\"text-align: start;\">Runs a given function or operation on the QuantumSimulator target machine.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%toffoli</td><td style=\"text-align: start;\">Runs a given function or operation on the ToffoliSimulator target machine.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%trace</td><td style=\"text-align: start;\">Visualizes the execution path of the given operation.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%who</td><td style=\"text-align: start;\">Lists the Q# operations available in the current session.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr><tr><td style=\"text-align: start;\">%workspace</td><td style=\"text-align: start;\">Provides actions related to the current workspace.</td><td style=\"text-align: start;\">Microsoft.Quantum.IQSharp.Kernel</td></tr></tbody></table>"
      ],
      "text/plain": [
       "Name                         Summary                                                                                           Assembly\n",
       "---------------------------- ------------------------------------------------------------------------------------------------- -------------------------------------\n",
       "%azure.connect               Connects to an Azure Quantum workspace or displays current connection status.                     Microsoft.Quantum.IQSharp.AzureClient\n",
       "%azure.execute               Submits a job to an Azure Quantum workspace and waits for completion.                             Microsoft.Quantum.IQSharp.AzureClient\n",
       "%azure.jobs                  Displays a list of jobs in the current Azure Quantum workspace.                                   Microsoft.Quantum.IQSharp.AzureClient\n",
       "%azure.output                Displays results for a job in the current Azure Quantum workspace.                                Microsoft.Quantum.IQSharp.AzureClient\n",
       "%azure.quotas                Displays a list of quotas for the current Azure Quantum workspace.                                Microsoft.Quantum.IQSharp.AzureClient\n",
       "%azure.status                Displays status for a job in the current Azure Quantum workspace.                                 Microsoft.Quantum.IQSharp.AzureClient\n",
       "%azure.submit                Submits a job to an Azure Quantum workspace.                                                      Microsoft.Quantum.IQSharp.AzureClient\n",
       "%azure.target                Sets or displays the active execution target for Q# job submission in an Azure Quantum workspace. Microsoft.Quantum.IQSharp.AzureClient\n",
       "%config                      Allows setting or querying configuration options.                                                 Microsoft.Quantum.IQSharp.Kernel\n",
       "%debug                       Steps through the execution of a given Q# operation or function.                                  Microsoft.Quantum.IQSharp.Kernel\n",
       "%estimate                    Runs a given function or operation on the ResourcesEstimator target machine.                      Microsoft.Quantum.IQSharp.Kernel\n",
       "%experimental.build_info     Reports build info for the experimental simulators.                                               Microsoft.Quantum.IQSharp.Kernel\n",
       "%experimental.noise_model    Gets, sets, saves, or loads a noise model used in simulating quantum operations.                  Microsoft.Quantum.IQSharp.Kernel\n",
       "%experimental.simulate_noise Runs a given function or operation on the OpenSystemsSimulator target machine.                    Microsoft.Quantum.IQSharp.Kernel\n",
       "%lsmagic                     Returns a list of all currently available magic commands.                                         Microsoft.Quantum.IQSharp.Kernel\n",
       "%lsopen                      Lists currently opened namespaces and their aliases.                                              Microsoft.Quantum.IQSharp.Kernel\n",
       "%package                     Provides the ability to load a NuGet package.                                                     Microsoft.Quantum.IQSharp.Kernel\n",
       "%performance                 Reports current performance metrics for this kernel.                                              Microsoft.Quantum.IQSharp.Kernel\n",
       "%project                     Provides the ability to view or add Q# project references.                                        Microsoft.Quantum.IQSharp.Kernel\n",
       "%simulate                    Runs a given function or operation on the QuantumSimulator target machine.                        Microsoft.Quantum.IQSharp.Kernel\n",
       "%toffoli                     Runs a given function or operation on the ToffoliSimulator target machine.                        Microsoft.Quantum.IQSharp.Kernel\n",
       "%trace                       Visualizes the execution path of the given operation.                                             Microsoft.Quantum.IQSharp.Kernel\n",
       "%who                         Lists the Q# operations available in the current session.                                         Microsoft.Quantum.IQSharp.Kernel\n",
       "%workspace                   Provides actions related to the current workspace.                                                Microsoft.Quantum.IQSharp.Kernel\n"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%lsmagic"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To get detailed usage information on any of these magic commands from within a Q# notebook, simply append `?` to its name."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/x-qsharp-data": "{\"AzureClient\":{},\"Name\":\"%azure.execute\",\"Kind\":0,\"Documentation\":{\"Summary\":\"Submits a job to an Azure Quantum workspace and waits for completion.\",\"Full\":null,\"Description\":\"\\r\\nThis magic command allows for submitting a Q# operation or function\\r\\nto be run on the specified target in the current Azure Quantum workspace.\\r\\nThe command waits a specified amount of time for the job to complete before returning.\\r\\n\\r\\nThe Azure Quantum workspace must have been previously initialized\\r\\nusing the [`%azure.connect` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.connect),\\r\\nand an execution target for the job must have been specified using the\\r\\n[`%azure.target` magic command](https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.target).\\r\\n\\r\\n#### Required parameters\\r\\n\\r\\n- Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\\r\\nor function name that has been defined either in the notebook or in a Q# file in the same folder.\\r\\n- Arguments for the Q# operation or function must also be specified as `key=value` pairs.\\r\\n\\r\\n#### Optional parameters\\r\\n\\r\\n- `jobName=<string>`: Friendly name to identify this job. If not specified,\\r\\nthe Q# operation or function name will be used as the job name.\\r\\n- `shots=<integer>` (default=500): Number of times to repeat execution of the\\r\\nspecified Q# operation or function.\\r\\n- `timeout=<integer>` (default=30): Time to wait (in seconds) for job completion\\r\\nbefore the magic command returns.\\r\\n- `poll=<integer>` (default=5): Interval (in seconds) to poll for\\r\\njob status while waiting for job execution to complete.\\r\\n\\r\\n#### Possible errors\\r\\n\\r\\n- `NotConnected`: Not connected to any Azure Quantum workspace.\\r\\n- `NoTarget`: No execution target has been configured for Azure Quantum job submission.\\r\\n- `NoOperationName`: No Q# operation name was specified for Azure Quantum job submission.\\r\\n- `InvalidTarget`: The specified execution target is not valid for Q# job submission in the current Azure Quantum workspace.\\r\\n- `UnrecognizedOperationName`: The specified Q# operation name was not recognized.\\r\\n- `InvalidEntryPoint`: The specified Q# operation cannot be used as an entry point for Azure Quantum job submission.\\r\\n- `JobSubmissionFailed`: Failed to submit the job to the Azure Quantum workspace.\\r\\n- `JobNotCompleted`: The specified Azure Quantum job has not yet completed.\\r\\n- `JobOutputDownloadFailed`: Failed to download results for the specified Azure Quantum job.\\r\\n- `JobFailedOrCancelled`: The specified Azure Quantum job failed or was cancelled.\\r\\n                    \",\"Remarks\":null,\"Examples\":[\"\\r\\nRun a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`\\r\\non the active target in the current Azure Quantum workspace:\\r\\n```\\r\\nIn []: %azure.execute MyOperation a=5 b=10\\r\\nOut[]: Submitting MyOperation to target provider.qpu...\\r\\n       Job successfully submitted for 500 shots.\\r\\n          Job name: MyOperation\\r\\n          Job ID: <Azure Quantum job ID>\\r\\n       Waiting up to 30 seconds for Azure Quantum job to complete...\\r\\n       [1:23:45 PM] Current job status: Waiting\\r\\n       [1:23:50 PM] Current job status: Executing\\r\\n       [1:23:55 PM] Current job status: Succeeded\\r\\n       <detailed results of completed job>\\r\\n```\\r\\n                        \",\"\\r\\nRun a Q# operation defined as `operation MyOperation(a : Int, b : Int) : Result`\\r\\non the active target in the current Azure Quantum workspace,\\r\\nspecifying a custom job name, number of shots, timeout, and polling interval:\\r\\n```\\r\\nIn []: %azure.submit MyOperation a=5 b=10 jobName=\\\"My job\\\" shots=100 timeout=60 poll=10\\r\\nOut[]: Submitting MyOperation to target provider.qpu...\\r\\n       Job successfully submitted for 100 shots.\\r\\n          Job name: My job\\r\\n          Job ID: <Azure Quantum job ID>\\r\\n       Waiting up to 60 seconds for Azure Quantum job to complete...\\r\\n       [1:23:45 PM] Current job status: Waiting\\r\\n       [1:23:55 PM] Current job status: Waiting\\r\\n       [1:24:05 PM] Current job status: Executing\\r\\n       [1:24:15 PM] Current job status: Succeeded\\r\\n       <detailed results of completed job>\\r\\n```\\r\\n                        \"],\"SeeAlso\":null}}",
      "text/html": [
       "<h4><i class=\"fa fas fa-magic\"></i> %azure.execute</h4><p>Submits a job to an Azure Quantum workspace and waits for completion.</p><h5>Description</h5><p>This magic command allows for submitting a Q# operation or function\n",
       "to be run on the specified target in the current Azure Quantum workspace.\n",
       "The command waits a specified amount of time for the job to complete before returning.</p>\n",
       "<p>The Azure Quantum workspace must have been previously initialized\n",
       "using the <a href=\"https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.connect\"><code>%azure.connect</code> magic command</a>,\n",
       "and an execution target for the job must have been specified using the\n",
       "<a href=\"https://docs.microsoft.com/qsharp/api/iqsharp-magic/azure.target\"><code>%azure.target</code> magic command</a>.</p>\n",
       "<h4>Required parameters</h4>\n",
       "<ul>\n",
       "<li>Q# operation or function name. This must be the first parameter, and must be a valid Q# operation\n",
       "or function name that has been defined either in the notebook or in a Q# file in the same folder.</li>\n",
       "<li>Arguments for the Q# operation or function must also be specified as <code>key=value</code> pairs.</li>\n",
       "</ul>\n",
       "<h4>Optional parameters</h4>\n",
       "<ul>\n",
       "<li><code>jobName=&lt;string&gt;</code>: Friendly name to identify this job. If not specified,\n",
       "the Q# operation or function name will be used as the job name.</li>\n",
       "<li><code>shots=&lt;integer&gt;</code> (default=500): Number of times to repeat execution of the\n",
       "specified Q# operation or function.</li>\n",
       "<li><code>timeout=&lt;integer&gt;</code> (default=30): Time to wait (in seconds) for job completion\n",
       "before the magic command returns.</li>\n",
       "<li><code>poll=&lt;integer&gt;</code> (default=5): Interval (in seconds) to poll for\n",
       "job status while waiting for job execution to complete.</li>\n",
       "</ul>\n",
       "<h4>Possible errors</h4>\n",
       "<ul>\n",
       "<li><code>NotConnected</code>: Not connected to any Azure Quantum workspace.</li>\n",
       "<li><code>NoTarget</code>: No execution target has been configured for Azure Quantum job submission.</li>\n",
       "<li><code>NoOperationName</code>: No Q# operation name was specified for Azure Quantum job submission.</li>\n",
       "<li><code>InvalidTarget</code>: The specified execution target is not valid for Q# job submission in the current Azure Quantum workspace.</li>\n",
       "<li><code>UnrecognizedOperationName</code>: The specified Q# operation name was not recognized.</li>\n",
       "<li><code>InvalidEntryPoint</code>: The specified Q# operation cannot be used as an entry point for Azure Quantum job submission.</li>\n",
       "<li><code>JobSubmissionFailed</code>: Failed to submit the job to the Azure Quantum workspace.</li>\n",
       "<li><code>JobNotCompleted</code>: The specified Azure Quantum job has not yet completed.</li>\n",
       "<li><code>JobOutputDownloadFailed</code>: Failed to download results for the specified Azure Quantum job.</li>\n",
       "<li><code>JobFailedOrCancelled</code>: The specified Azure Quantum job failed or was cancelled.</li>\n",
       "</ul>\n",
       "<h5>Example</h5><p>Run a Q# operation defined as <code>operation MyOperation(a : Int, b : Int) : Result</code>\n",
       "on the active target in the current Azure Quantum workspace:</p>\n",
       "<pre><code>In []: %azure.execute MyOperation a=5 b=10\n",
       "Out[]: Submitting MyOperation to target provider.qpu...\n",
       "       Job successfully submitted for 500 shots.\n",
       "          Job name: MyOperation\n",
       "          Job ID: &lt;Azure Quantum job ID&gt;\n",
       "       Waiting up to 30 seconds for Azure Quantum job to complete...\n",
       "       [1:23:45 PM] Current job status: Waiting\n",
       "       [1:23:50 PM] Current job status: Executing\n",
       "       [1:23:55 PM] Current job status: Succeeded\n",
       "       &lt;detailed results of completed job&gt;\n",
       "</code></pre>\n",
       "<h5>Example</h5><p>Run a Q# operation defined as <code>operation MyOperation(a : Int, b : Int) : Result</code>\n",
       "on the active target in the current Azure Quantum workspace,\n",
       "specifying a custom job name, number of shots, timeout, and polling interval:</p>\n",
       "<pre><code>In []: %azure.submit MyOperation a=5 b=10 jobName=&quot;My job&quot; shots=100 timeout=60 poll=10\n",
       "Out[]: Submitting MyOperation to target provider.qpu...\n",
       "       Job successfully submitted for 100 shots.\n",
       "          Job name: My job\n",
       "          Job ID: &lt;Azure Quantum job ID&gt;\n",
       "       Waiting up to 60 seconds for Azure Quantum job to complete...\n",
       "       [1:23:45 PM] Current job status: Waiting\n",
       "       [1:23:55 PM] Current job status: Waiting\n",
       "       [1:24:05 PM] Current job status: Executing\n",
       "       [1:24:15 PM] Current job status: Succeeded\n",
       "       &lt;detailed results of completed job&gt;\n",
       "</code></pre>\n"
      ],
      "text/plain": [
       "%azure.execute:\n",
       "Submits a job to an Azure Quantum workspace and waits for completion."
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%azure.execute?"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Q#",
   "language": "qsharp",
   "name": "iqsharp"
  },
  "language_info": {
   "file_extension": ".qs",
   "mimetype": "text/x-qsharp",
   "name": "qsharp",
   "version": "0.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
